﻿// ===============================================================================
// XCI.WinForm.Platform 西安交通信息WinForm开发框架 2019 版权所有
// ===============================================================================

using System.Collections.Generic;
using XCI.Sys.Model;
using XCI.Sys.Service;
using XCI.Windows;
using XCI.Windows.Controls;

namespace XCI.Sys.Controls
{
    [System.ComponentModel.DesignerCategory("Code")]
    public class UserComboGridEdit : ComboGridEditx
    {
        private readonly AsyncWorker asyncWorker = new AsyncWorker();
        public override string Id => "ca8e9cbf039d4ee493cb15414982941e";
        public override string ValueMember => "Id";
        public override string DisplayMember => "Name";

        protected override void OnCreateControl()
        {
            base.OnCreateControl();
            if (!DesignMode)
            {
                List<SysUserSimple> list = null;
                asyncWorker
                    .RunCallback(e => { list = UserService.Instance.SelectSimpleList(null, null, true); })
                    .CompletCallback(e => { base.DataSource = list; })
                    .RunAsync();
            }
        }
    }
}